package main

import (
	"fmt"
	"time"

)

func main(){
	var table = make(chan int)
	var ball int

	go player("wang", table)
	go player("li", table)
	// 游戏一秒后结束
	table <- ball
	time.Sleep(time.Second * 1)
	<-table
}

func player(name string, table chan int){
	for {
		ball := <- table
		fmt.Println(name+" : " + "get ball>>>", ball)
		time.Sleep(time.Millisecond * 500)
		fmt.Println(name + " : " + "bakc ball>>>", ball)
		ball++
		table <- ball
	}
}